﻿#include "redis_data.h"

void CRedisDbData::OptCommand(const std::string &id, const std::string &queryString)
{
	m_datas[id].emplace_back(S_RedisDataType{ e_opt_command, queryString });
}

RedisDataTypeVector &CRedisDbData::GetData(const std::string &id)
{
	static RedisDataTypeVector g_empty_data;
	auto it = m_datas.find(id);
	if (it != m_datas.end())
	{
		return it->second;
	}
	return g_empty_data;
}

void CRedisDbData::RemoveData(const std::string &id)
{
	m_datas.erase(id);
}

unsigned CRedisDbData::GetDataState(const std::string &id)
{
	auto it = m_dataState.find(id);
	if (it != m_dataState.end())
	{
		return it->second;
	}
	return e_opt_state_idle;
}

void CRedisDbData::SetDataState(const std::string &id, unsigned state)
{
	m_dataState[id] = state;
}